package com.luych.toolbox.docker.service.dao;

import com.luych.toolbox.docker.service.entity.DockerStat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.Date;
import java.util.List;
import java.util.Optional;

public interface DockerStatDao extends JpaRepository<DockerStat, String>, JpaSpecificationExecutor<DockerStat> {

    List<DockerStat> findByServerIdAndContainerIdAndCreateDateBetween(String serverId, String containerId, Date start, Date end);

    Optional<DockerStat> findFirstByServerIdAndContainerIdOrderByCreateDateDesc(String serverId, String containerId);

    void deleteByServerId(String serverId);

    void deleteByServerIdAndContainerId(String serverId, String containerId);

    void deleteByServerIdAndContainerIdNotIn(String serverId, List<String> containerIds);

}